package com.eipc;

import com.eipc.util.UpdateManager;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;

public class UpdateProgressActivity extends Activity {
	private ProgressView mView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	mView = new ProgressView(UpdateProgressActivity.this);
    	setContentView(mView);
    }
    
    class ProgressView extends View{
    	private Paint mPaint;
    	private int w;
    	private int h;

		public ProgressView(Context cx) {
			super(cx);
			mPaint = new Paint();
			mPaint.setColor(Color.BLUE);
			mPaint.setTextSize(16);
			DisplayMetrics dm = cx.getApplicationContext().getResources().getDisplayMetrics();
			w  = dm.widthPixels;
			h  = dm.heightPixels;
		}
		
		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			canvas.drawColor(Color.WHITE);
			Paint p0 = new Paint();
			p0.setColor(Color.GREEN);
			canvas.drawRect(10,h/2-10,w-10,h/2+10,p0);
			Paint p1 = new Paint();
			p1.setColor(Color.YELLOW);
			canvas.drawRect(10,h/2-10,(w-20)*(1f*UpdateManager.cLen/UpdateManager.len)+10,h/2+10,p1);
			canvas.drawText(UpdateManager.cLen+"/"+UpdateManager.len+" "+((int)(1f*UpdateManager.cLen/UpdateManager.len*10000))/100f+"%", w/2-50,h/2-8,mPaint);
			invalidate();
		}
    	
    }
}
